<template>
  <el-dialog
    :close-on-click-modal="false"
    :visible="visible"
    :title="`${'审核案件 - ' + formData.case_number}`"
    :before-close="onClose"
    width="60%"
    :style="{ 'max-height': '100vh' }"
  >
      <el-form
        style="padding: 0 30px"
        ref="form"
        label-width="120px"
        :model="form"
        :rules="rules"
      >
            <el-form-item label="案件号" prop="case_number">
              <el-input
                placeholder="请输入案件号"
                disabled
                v-model="form.case_number"
              ></el-input>
            </el-form-item>
            <el-form-item label="保险核损价格" prop="write_off_price">
              <el-input
                placeholder="请输入保险核损价格"
                v-model="form.write_off_price"
              ></el-input>
            </el-form-item>
            <el-form-item label="是否需要维修" prop="is_repair">
              <el-radio-group v-model="form.is_repair">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="竞标价格" prop="bid_price">
              <el-input
                placeholder="请输入竞标价格"
                v-model="form.bid_price"
              ></el-input>
            </el-form-item>
            <el-form-item label="是否中标" prop="is_bidder">
              <el-radio-group v-model="form.is_bidder">
                <el-radio :label="0">否</el-radio>
                <el-radio :label="1">是</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="备注" prop="describe">
          <el-input
            v-model="form.describe"
            type="textarea"
            placeholder="请输入备注"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="footer">
        <el-button @click="onClose">取 消</el-button>
        <el-button type="primary" @click="onEnter">提 交</el-button>
      </div>
  </el-dialog>
</template>

<script>
export default {
  name: "serviceEdit",
  components: {},
  data() {
    return {
      form: {},
      rules: {
        write_off_price: [{ required: true, message: "必需", trigger: ["blur"] }],
        is_repair: [{ required: true, message: "必需", trigger: ["blur"] }],
        bid_price: [{ required: true, message: "必需", trigger: ["blur"] }],
        is_bidder: [{ required: true, message: "必需", trigger: ["blur"] }],
      },
      dialogVisible: false,
    };
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    formData: {
      type: Object,
      default() {
        return {};
      },
    }
  },
  created() {},
  computed: {},
  watch: {
    formData(e) {
      this.form = {
        ...e,
      };
    },
    visible(v) {
      v && this.validateReset();
    },
  },
  methods: {
    validateReset() {
      this.$refs.form && this.$refs.form.clearValidate();
    },
    onClose() {
      this.$emit("onClose");
    },
    onEnter() {
      this.$refs.form.validate((res) => {
        if (res) {
          this.$emit("onEnter", this.form);
        }
      });
    },
  },
};
</script>
<style scoped>
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
